﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;

public partial class Xemthongtinuser : System.Web.UI.Page
{
    SqlConnection con;
    DataTable dt = new DataTable();
    private string Connect = ConfigurationManager.ConnectionStrings["ketnoi"].ConnectionString;
    
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["username"].ToString() != "")
        {
            lbluser.Text = "" + Session["username"].ToString();
            string sql = "select TenDangNhap,Email,CMND,HoVaTen,NgaySinh,DienThoai,DiaChi,Tinh_TP from Dang_Nhap where TenDangNhap='" +lbluser.Text + "'";
            con = new SqlConnection(Connect);
            try
            {
                con.Open();
                SqlCommand cmd = con.CreateCommand();
                cmd.CommandText = sql;
                SqlDataReader reader = cmd.ExecuteReader(CommandBehavior.SingleRow);
                while (reader.Read())
                {
                    txttendangnhap.Text = lbluser.Text;
                    txtEmail.Text = reader[1].ToString();
                    txtcmnd.Text = reader[2].ToString();
                    txthovaten.Text = reader[3].ToString();
                    txtngaysinh.Text = reader[4].ToString();
                    txtdienthoai.Text = reader[5].ToString();
                    txtdiachinhanhang.Text = reader[6].ToString();
                    txttinhtp.Text = reader[7].ToString();
                }
            }
            catch { }
            
        }
        else
        {
            Response.Redirect("DangNhap.aspx");
        }        
        
    }
    
}
